package com.ruoyi.asms.controller;

import com.ruoyi.asms.domain.AsmsOwnChargeInfo;
import com.ruoyi.asms.service.IAsmsOwnChargeInfoService;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.security.annotation.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**export
 * 资产所有非负责人负责信息Controller
 * 
 * @author yfkj
 * @date 2021-10-21
 */
@RestController
@RequestMapping("/asms/AsmsOwnChargeInfo")
public class AsmsOwnChargeInfoController extends BaseController
{
    @Autowired
    private IAsmsOwnChargeInfoService asmsOwnChargeInfoService;

    /**
     * 查询资产所有非负责人负责信息列表
     */
    @PreAuthorize
    //@PreAuthorize(hasPermi = "asms:AsmsOwnChargeInfo:list")
    @GetMapping("/list")
    public TableDataInfo list(AsmsOwnChargeInfo asmsOwnChargeInfo)
    {
        startPage();
        List<AsmsOwnChargeInfo> list = asmsOwnChargeInfoService.selectAsmsOwnChargeInfoList(asmsOwnChargeInfo);
        return getDataTable(list);
    }

    /**
     * 导出资产所有非负责人负责信息列表
     */
    @PreAuthorize
    //@PreAuthorize(hasPermi = "asms:AsmsOwnChargeInfo:export")
    @Log(title = "资产所有非负责人负责信息", businessType = BusinessType.EXPORT)
    @PostMapping(value="/export", produces = "application/octet-stream")
    public void export(HttpServletResponse response, AsmsOwnChargeInfo asmsOwnChargeInfo) throws IOException
    {

        List<AsmsOwnChargeInfo> list = asmsOwnChargeInfoService.selectAsmsOwnChargeInfoList(asmsOwnChargeInfo);
        ExcelUtil<AsmsOwnChargeInfo> util = new ExcelUtil<AsmsOwnChargeInfo>(AsmsOwnChargeInfo.class);
        util.exportExcel(response, list, "资产所有非负责人负责信息数据");
    }

    /**
     * 获取资产所有非负责人负责信息详细信息
     */
    @PreAuthorize
    //@PreAuthorize(hasPermi = "asms:AsmsOwnChargeInfo:query")
    @GetMapping(value = "/{ownChargeInfoId}")
    public AjaxResult getInfo(@PathVariable("ownChargeInfoId") Long ownChargeInfoId)
    {
        return AjaxResult.success(asmsOwnChargeInfoService.selectAsmsOwnChargeInfoByOwnChargeInfoId(ownChargeInfoId));
    }

    /**
     * 新增资产所有非负责人负责信息
     */
    @PreAuthorize
    //@PreAuthorize(hasPermi = "asms:AsmsOwnChargeInfo:add")
    @Log(title = "资产所有非负责人负责信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AsmsOwnChargeInfo asmsOwnChargeInfo)
    {
        return toAjax(asmsOwnChargeInfoService.insertAsmsOwnChargeInfo(asmsOwnChargeInfo));
    }

    /**
     * 修改资产所有非负责人负责信息
     */
    @PreAuthorize
    //@PreAuthorize(hasPermi = "asms:AsmsOwnChargeInfo:edit")
    @Log(title = "资产所有非负责人负责信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AsmsOwnChargeInfo asmsOwnChargeInfo)
    {
        return toAjax(asmsOwnChargeInfoService.updateAsmsOwnChargeInfo(asmsOwnChargeInfo));
    }

    /**
     * 删除资产所有非负责人负责信息
     */
    @PreAuthorize
    //@PreAuthorize(hasPermi = "asms:AsmsOwnChargeInfo:remove")
    @Log(title = "资产所有非负责人负责信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ownChargeInfoIds}")
    public AjaxResult remove(@PathVariable Long[] ownChargeInfoIds)
    {
        return toAjax(asmsOwnChargeInfoService.deleteAsmsOwnChargeInfoByOwnChargeInfoIds(ownChargeInfoIds));
    }
}
